#include "functions.h"

void selection( const int* number_selections ){
  int i, j, k, n;
  int times;

  k = 0;
  for(i = 0; i< number_of_layers; i++){
    if( number_selections[ i ] > each_individuals )
      times = number_selections[ i ];
    else
      times = each_individuals;

    qsort(layers[ i ].offspring_individuals, times, sizeof(INDIVIDUAL), (int(*)(const void*, const void*))individual_comp);

    for( j=0; j<number_selections[ i ]; j++ )
      {
	for( n=0; n<number_of_dimensions; n++ )
	  {
	    individuals[ k ].design_variables[ n ] = layers[ i ].offspring_individuals[ j ].design_variables[ n ];
	    individuals[ k ].function_value = layers[ i ].offspring_individuals[ j ].function_value;
	  }
	k++;
      }
  }
}
